package com.kaiwukj.android.ufamily.mvp.ui.page.service.order;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.app.base.review.BaseActivity;
import com.kaiwukj.android.ufamily.app.constant.ARouterUrlKt;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = ARouterUrlKt.OrderResultUrl)
public class OrderResultActivity extends BaseActivity {

    public static final int ORDER_PAY = 1;//支付成功
    public static final int ORDER_REFUND = 2;//退款

    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_result)
    ImageView ivResult;
    @BindView(R.id.tv_result)
    TextView tvResult;
    @BindView(R.id.tv_msg)
    TextView tvMsg;

    @Autowired
    int type;
    @Autowired
    String appointmentTime;
    @Autowired
    int orderId;
    @Autowired
    String orderNo;

    @OnClick(R.id.container_left)
    void onBackClick() {
        onBackPressedSupport();
    }

    @OnClick({R.id.btn_back_service, R.id.btn_order_detail})
    void onBtnClick(View view) {
        switch (view.getId()) {
            case R.id.btn_back_service:
                ARouter.getInstance().build(ARouterUrlKt.MainRouterUrl)
                        .navigation();
                break;
            case R.id.btn_order_detail:
                ARouter.getInstance().build(ARouterUrlKt.OrderDetailUrl)
                        .withInt("orderId", orderId)
                        .navigation();
                break;
        }
    }


    @Override
    protected int getLayoutId() {
        ARouter.getInstance().inject(this);
        return R.layout.activity_order_result;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        if (type == ORDER_PAY) {
            tvTitle.setText("支付成功");
            tvResult.setText("支付成功");
            tvMsg.setText(String.format("预计上门时间 %s", appointmentTime));
        } else {
            tvTitle.setText("提交成功");
            tvResult.setText("退款申请已提交");
            tvMsg.setText("您可以在订单详情中查看退款信息");
        }
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Override
    public void onBackPressedSupport() {
        ARouter.getInstance().build(ARouterUrlKt.MainRouterUrl)
                .navigation();
    }
}
